import {request, writeLog} from "@/libs/core.js"
import { Message } from 'element-ui'
/**
会员登录校验逻辑
@param args{account:xxx. loginpw:xxx, vcode:xxxx}
****************************************************************/
const getList = async(args) => {
    const data = await request({url:'/api/core/org/tree', data:args, method:'post'});
    if (data && data.code == 0 ) {
        return data;
    }
    return false
}

const doDelete = async(args) => {
	const data = await request({url:'/api/core/org/delete', data:args, method:'post'});
	if(data && data.code == 0){
		Message({message: '组织结构信息删除成功', type: 'success', duration: 3 * 1000});
		return true
	}
    return false
}

const doSave = async(args) => {
	const data = await request({url:'/api/core/org/update', data:args, method:'post'});
	if(data && data.code == 0){
		if(!args.id){
			Message({message: '组织结构信息新增成功', type: 'success', duration: 3 * 1000});
		}else{
			Message({message: '组织结构信息编辑成功', type: 'success', duration: 3 * 1000});
		}
		return true
	}
    return false
}

export default {
	getList, doDelete, doSave
};
